package com.acme;
/**
 * Class processes and stores handled program arguments.
 */
class ArgsHandler {
    private static final String PARAMETER_LOAD_FEED = "-loadfeed";
    private static final String PARAMETER_LOAD_BANK = "-loadbank";
    private static final String PARAMETER_SERVER = "-server";
    private static final String PARAMETER_STATISTICS = "-statistics";

    private String pathFeedFrom;
    private String pathBankLoadFrom;
    private String pathBankSaveTo;
    private boolean server;
    private boolean statistics;

    public ArgsHandler(String [] args) {
        parseArgs(args);
    }

    private void parseArgs(String [] args) {
        for (int i = 0; i < args.length; i++) {
            if (args[i].equals(PARAMETER_LOAD_BANK)) {
                pathBankLoadFrom = args[i + 1];
                pathBankSaveTo = pathBankLoadFrom;
            }
            if (args[i].equals(PARAMETER_LOAD_FEED)) {
                pathFeedFrom = args[i + 1];
            }

            if (args[i].equals(PARAMETER_SERVER)) {
                server = true;
            }

            if (args[i].equals(PARAMETER_STATISTICS)) {
                statistics = true;
            }
        }
    }

    /**
     * Method returns the path to feed file.
     *
     * @return String to feed file
     */
    public String getPathFeedFrom() {
        return pathFeedFrom;
    }

    /**
     * Show that application should be runned as server.
     *
     * @return
     */
    public boolean isServer() {
        return server;
    }

    /**
     * Method returns the path from that loads bank object.
     *
     * @return path to serialized Bank object
     */
    public String getPathBankLoadFrom() {
        return pathBankLoadFrom;
    }

    /**
     * Method returns the path where the file is saved.
     *
     * @return
     */
    public String getPathBankSaveTo() {
        return pathBankSaveTo;
    }

    /**
     * Indicates that the application should or should not output statistics of the bank.
     *
     * @return
     */
    public boolean isStatistics() {
        return statistics;
    }


}